package com.qcby.controller;

import com.qcby.entity.Student;
import com.qcby.entity.Teachers;
import com.qcby.entity.vo.StudentVo;
import com.qcby.entity.vo.TeachersVo;
import com.qcby.service.StudentService;
import com.qcby.service.TeachersService;
import com.qcby.util.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;

/**
 * @author haozeWang
 * @create 2021-08-23 17:54
 */
@Controller
@RequestMapping("/teachers")
public class TeachersController {
    @Autowired
    private TeachersService teachersService;
    /*查所有*/
    @RequestMapping("/selectall")
    @ResponseBody
    public ResultObject selectAll(TeachersVo teachersVo){
        ResultObject object = teachersService.selectAll(teachersVo);
        return object;
    }

    /*删除单个教师*/
    @RequestMapping("/delete")
    @ResponseBody
    public ResultObject delete(Integer id){
        ResultObject object = teachersService.delete(id);
        return object;
    }
    /*延迟加载教师授课班级信息*/
    @RequestMapping("/classList")
    @ResponseBody
    public ResultObject classList(Integer id){
        ResultObject object = teachersService.selectById(id);
        return object;
    }

    /*添加单个教师*/
    @RequestMapping("/add")
    @ResponseBody
    public ResultObject add(TeachersVo teachersVo){
        ResultObject object = teachersService.add(teachersVo);
        return object;
    }
    /*修改单个教师*/
    @RequestMapping("/update")
    @ResponseBody
    public ResultObject update(TeachersVo teachersVo){
        ResultObject object = teachersService.update(teachersVo);
        return object;
    }
    /*批量删除教师*/
    @RequestMapping("/deletedisp")
    @ResponseBody
    public ResultObject deletedisp(@RequestBody ArrayList<Integer> ids){
       ResultObject object = teachersService.deleteDisp(ids);
        return object;
    }

}
